<div class="contentArea" ng-app="myApp" ng-controller="myController">
    <div class="Item hr">
        <div class="current">添加文章</div>
    </div>
    <form>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
            <tr>
                <th width="90">文章名称：</th>
                <td><input type="text" class="input" size="50" placeholder="请输入标题" name="data[title]"/></td>
            </tr>

            <tr>
                <th width="90">文章简介：</th>
                <td><textarea class="jq_watermark" rows = "5" cols="68" name="data[intro]" placeholder="输入文章简介"></textarea></td>
            </tr>

            <tr>
                <th width="90">上传图片：</th>
                <td>
                    <input type="file" id="pic" name="pic">
                </td>
                <div class="id_photos" >

                </div>
            </tr>

            <tr>
                <th width="90">选择小说：</th>
                <td>
                    <input style="height: 30px;" ng-model="data.keyword" placeholder="&nbsp;请输入要搜索的小说名称"><input style="width: 50px; height: 30px;margin-left: 10px;" type='button' id="submit_novel" ng-click="search_novel();" value='搜索'>
                    <select ng-model="data.novel_id" style="width: 235px;margin-top: 10px;display: none;" id="show_novel_list" name="data[novel_id]">
                        <option value="" selected>请选择小说</option>
                        <option ng-repeat="item in novel_list" value="{{item.id}}">{{item.title}}</option>
                    </select>
                </td>
            </tr>
        </table>
    </form>
    <div class="commonBtnArea">
        <button class="btn submit">提交</button>
    </div>
</div>

<script type="text/javascript" src="__PUBLIC__/javascripts/admin/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/javascripts/admin/angular.min.js"></script>

<script type="text/javascript">
    var app = angular.module('myApp',[]);
    app.controller('myController',function($scope){
        $scope.data = {keyword:''};
        $scope.novel_list = [{id:'',title:''}];     //小说列表

        //搜索小说
        $scope.search_novel = function(){
            if($scope.data.keyword == ''){
                layer.alert("请输入搜索内容",{icon:2});return false;
            }

            $.post("{:U('Novel/search_novels')}",{keyword:$scope.data.keyword},function(data){
                if(data.code == 0){
                    $('#show_novel_list').show();
                    $scope.$apply(function(){
                        $scope.novel_list = data.list;
                    })
                }else{
                    layer.alert(data.msg,{icon:2});
                }
            },'json')
        }


        $(".submit").click(function(){
            commonAjaxSubmit("{:U('Article/insert')}");
        });
    });


</script>

